﻿using UnityEngine;
using System.Collections;

public class plankDropScript : MonoBehaviour {

	float targetPos;
	public float dropTiming;
	bool isDropping;
	float yVel;
	public bool finishDropping;
	
	
	// Use this for initialization
	void Start () {
		yVel = 0;
		finishDropping = false;
	}
	
	// Update is called once per frame
	void Update () {
		if(!finishDropping && isDropping)
		{
			yVel += Time.deltaTime;
			Vector3 tmpPos = transform.position;
			tmpPos.y -= yVel;
			transform.position = tmpPos;
			if(tmpPos.y <= targetPos)
			{
				tmpPos.y = targetPos;
				transform.position = tmpPos;
				finishDropping = true;
			}
		}
	}
	
	public void dropPlankTo(float posY)
	{
		targetPos = posY;
		isDropping = true;
	}
}
